/**
 * Copyright 2010 Victor Egea Hernando
 *
 * RockScript is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 * 
 * RockScript is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with RockScript.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef INSTRUCTION_H_
#define INSTRUCTION_H_

#include <corelib/types.h>

namespace paper{

typedef struct{
    // second & third operands
    corelib::uint8 _b, _c;
} __bc_operators;

typedef union{
    // z operand
    corelib::int16 _z;
    // operators b & c 
    __bc_operators _bc;
} __inst_last16b;

typedef struct{
    // type of operator
    corelib::uint8 _op;
    // first operand
    corelib::uint8 _a;
    // rest of operands
    __inst_last16b _rest;
} __instruction;

class instruction{

public:
    // constructrs & destructor
    instruction();
    instruction( const __instruction &val );
    instruction( corelib::uint8 op, corelib::uint8 a, corelib::int16 z );
    instruction( corelib::uint8 op, corelib::uint8 a, corelib::uint8 b, corelib::uint8 c );

    // transfrom to binary & string form
    __instruction &bin( void );
    std::string str( void );

    // instruction fields
    __instruction _inst;
};

}; // namespace paper;

#endif // INSTRUCTION_H_
